import pandas as pd
import csv
import os
from IPython import embed
from git import Repo
from mailing import send_mail_cse_smtp
from collections import defaultdict
from sys import argv
import traceback
import logging


subject = "CSCI3100 Final Exam Dry Run Mark"

msg = """
Dear Student

Congratulations! You have participated in and successfully submitted answers in the Final Exam dry run. You’ve got one full point in the final grade of the CSCI3100 course.

Please remember to submit Classroom Teaching Evaluation (CTE) for this course if you haven’t done it.  Check your email for CSCI3100 CTE.

See you in the Final Exam!

-CSCI3100 teaching team
"""


group_prefix = ""  # for TA use

if __name__ == "__main__":
    df = pd.read_excel("./final-dryrun-mark.xlsx")
    print(df.shape)
    passed = df[df["Dryrun Mark"] == 1]
    print(passed.shape)

    bcc_list = passed["Student ID"].map(lambda x: str(x) + "@link.cuhk.edu.hk").tolist()
    receiver_list = ["csci3100@cse.cuhk.edu.hk"]

    # print(bcc_list, len(bcc_list))
    # uncomment it to send emails
    send_mail_cse_smtp(
        "csci3100",  # cse username
        subject,  # subject
        msg,  # content
        None,  # no attachment
        receiver_list,  # receiver list
        bcc=bcc_list,
    )

    print("Done")
